﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using WebApplication2.Dtos;
using WebApplication2.ErrorCode;

namespace WebApplication2.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class MesController : ControllerBase
    {
        [HttpPost]
        public IActionResult PushData([FromBody] InputPushDataDTO person)
        {
            var inputPushDataDtos=new List
            //http://localhost:5021/swagger/index.html
            using var client=new HttpClient();
            client.BaseAddress = new Uri("http://localhost:5021");
            var response = client.PatchAsJsonAsync("/api/Mes/WatchPush", person).Result;
            if(response.IsSuccessStatusCode)
            {
                var result = response.Content.ReadAsStringAsync().Result;
                var list= JsonConvert.DeserializeObject<APIResult<PushData>>(result);
                return Ok(list);
            }
            else
            {
                return BadRequest("请求失败");
            }
        }
    }
}
